import java.util.*;
public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        sc.nextLine();
        for (int k = 0; k < T; k++) {
            int N = sc.nextInt();
            sc.nextLine();
            int[] ax = new int[N];
            for (int i = 0; i < N; i++) {
                ax[i] = sc.nextInt();
            }
            sc.nextLine();
            int[][] len = new int[N][N];
            for (int i = 0; i < N; i++) {
                len[i][i] = ax[i];
            }
            for (int t = 0; t < N - 1; t++) {
                int u = sc.nextInt();
                int v = sc.nextInt();
                sc.nextLine();
                len[u][v] = ax[u] | ax[v];
                len[v][u] = ax[u] | ax[v];
                for (int i = 0; i < N; i++) {
                    for (int j = i + 1; j < N; j++) {

                    }
                }
            }


        }

    }



}